import { Rule, RuleType } from '@midwayjs/decorator';

class BaseProductDto {
  @Rule(RuleType.string())
  title: string;

  @Rule(RuleType.string())
  poster: string;

  @Rule(RuleType.boolean())
  sale: boolean;

  @Rule(RuleType.array())
  categoryId: number[];

  @Rule(RuleType.array())
  keyword: string[];

  @Rule(RuleType.array())
  carousel: string[];

  @Rule(RuleType.array())
  detail: string[];
}

// 创建：需要提供关键属性
export class CreateProductDto extends BaseProductDto {
  @Rule(RuleType.string().required())
  title: string;

  @Rule(RuleType.string().required())
  poster: string;

  @Rule(RuleType.boolean().default(false))
  sale: boolean;

  @Rule(RuleType.array().required())
  categoryId: number[];
}

// 更新：需要 id，其他可选
export class UpdateProductDto extends BaseProductDto {
  @Rule(RuleType.number().required())
  id: number;
}
